package com.atstudy.servlet;

import com.atstudy.entites.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/2/1 14:51
 * @copyright: 博为峰
 */
@WebServlet("/stu")
public class StudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        HttpSession session = req.getSession();
//        User user = (User) session.getAttribute("user");
//        if (user != null) {
            //登录过
            System.out.println("StudentServlet");
            String method = req.getParameter("method");
            if (method.equals("add")) {
                this.add();
            } else if (method.equals("del")) {
                this.del();
            }
//        } else {
//            //先登录
//            resp.sendRedirect(req.getContextPath() + "/login.jsp");
//        }
    }

    public void add() {
        System.out.println("StudentServlet add");
    }

    public void del() {
        System.out.println("StudentServlet del");
    }
}
